package com.example.hello;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
public class controler {



    @GetMapping("/hello")
    public String hello() {
        return "get: hello world"+nameAges.toString();
    }

    private static HashMap<String,Integer> nameAges = new HashMap<>();

    @PostMapping("/hello")
    public String helloPost(String name,int age) {
        nameAges.put(name,age);
        return "post: add name: "+name+"age= "+age;
    }

    @PutMapping("/hello")
    public String helloPut(String name,int age) {
        nameAges.replace(name,age);
        return "put: update name: "+name+"age= "+age;
    }

    @DeleteMapping("/hello/{name}")
    public String helloDel(@PathVariable String name) {
        nameAges.remove(name);
        return "del name: "+name;
    }

}